<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\web\View;

/* @var $this yii\web\View */
/* @var $model common\models\AuthItem */
/* @var $form yii\widgets\ActiveForm */
$this->registerCssFile('/checkbox/css/index.css');
$this->registerCssFile('/checkbox/css/labelauty.css');
$this->registerJsFile('/checkbox/js/labelauty.js', [
    'depends' => 'yii\web\YiiAsset',
    'postion' => View::POS_END
]);
$this->registerJs('
            $(".rdolist").labelauty("rdolist", "rdo");
            $(".chklist").labelauty("chklist", "check");
        ');
?>
<?php if($model->isNewRecord || $model->type==1):?>
<div class="auth-item-role-form col-md-5">
	<h1>添加角色</h1>
    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => 25])?>

    <?= $form->field($model, 'type')->hiddenInput(['value'=>1])->label(false)?>
	<?= $form->field($model, 'description')->textInput(['maxlength' => 25])?>
	<?=$form->field($model, 'child')->checkboxList(ArrayHelper::map($data, 'name', 'description'), ['item' => function ($index, $label, $name, $checked, $value) {$checked = $checked ? "checked" : "";$return = '<input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '" class="chklist" ' . $checked . '/>';$return .= '<label class="chkbox"> <span class="check-image"></span><span class="radiobox-content">' . ucwords($label) . '</span></label>';return $return;}])?>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
<?php endif;?>
<?php if($model->isNewRecord || $model->type==2):?>
<div class="auth-item-form col-md-5">
	<h1>添加权限</h1>
    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true])?>

    <?= $form->field($model, 'type')->hiddenInput(['value'=>2])->label(false)?>
	<?= $form->field($model, 'description')->textInput(['maxlength' => 25])?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
<?php endif;?>
